package com.example.bootdemo;


import com.example.bootdemo.listeners.*;
import org.springframework.amqp.core.*;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class BootDemoApplication {

	public static void main(String[] args) {

		SpringApplication springApplication = new SpringApplication(BootDemoApplication.class);

//		MyAppStartingListener myAppStartingListener = new MyAppStartingListener();
//
//		MyAppEnvPreparedListener myAppEnvPreparedListener = new MyAppEnvPreparedListener();
//
//		MyAppStartListener myAppStartListener = new MyAppStartListener();
//
//		ApplicationReadyListener applicationReadyListener = new ApplicationReadyListener();
//
//		springApplication.addListeners(myAppStartingListener,myAppEnvPreparedListener,myAppStartListener,applicationReadyListener);


		springApplication.run(args);

	}

	@Bean
	public ApplicationRunner runner(AmqpTemplate template) {
		return args -> template.convertAndSend("myqueue", "foo");
	}


	@Bean
	public Queue myQueue() {
		return new Queue("myqueue");
	}

	@RabbitListener(queues = "myqueue")
	public void listen(String in) {
		System.out.println(in);
	}


}
